package com.gemme.gemme.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.gemme.gemme.R;
import com.gemme.gemme.shequ.GuanzhuFragment;

import java.util.ArrayList;

public  class StrGuigeAdapter extends RecyclerView.Adapter<StrGuigeAdapter.ViewHolder>{
    private ArrayList<String> adapterList;

    public StrGuigeAdapter(ArrayList<String> AdapterList){

        adapterList = AdapterList;
    }
    @NonNull
    @Override
    public StrGuigeAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(parent.getContext()).
                inflate(R.layout.item_str_guige, null);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        inflate.setLayoutParams(layoutParams);
        return new StrGuigeAdapter.ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull StrGuigeAdapter.ViewHolder holder, int position) {
        try {
            String s = adapterList.get(position);
            holder.tv.setText(s);
        }catch (Exception e){

        }
    }

    @Override
    public int getItemCount() {
        return adapterList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView tv;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);

            tv = itemView.findViewById(R.id.tv);
        }
    }
}
